package com.kun.controller;

import com.kun.service.service.FastDfsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/files")
public class FilesController {

    private final FastDfsService fastDfsService;

    public FilesController(FastDfsService fastDfsService) {
        this.fastDfsService = fastDfsService;
    }

    /**
     * 文件上传
     */
    @PostMapping("/upload")
    public String upload(MultipartFile file) {
        return fastDfsService.upload(file);
    }

    /**
     * 文件删除
     */
    @PostMapping("/delete")
    public boolean delete(String groupName, String fileName) {
        return fastDfsService.delete(groupName, fileName);
    }

}
